package com.coderman.utils.kvpair;

import java.util.Objects;

/**
 * description: KVParentPair <br>
 * date: 2020/9/6 16:09 <br>
 * author: coderman <br>
 * version: 1.0 <br>
 * 具有父子级关系的三元组
 */
public class KVParentPair<K,V,P> extends KVPair<K,V> {
    private P p;
    public KVParentPair(){}

    public KVParentPair(K k,V v ,P p){
        super(k,v);
        this.p = p;
    }

    public P getP() {
        return p;
    }

    public void setP(P p) {
        this.p = p;
    }

    public static <K, V> KVPair<K, V> build(K k, V v) {
        return new KVPair<>(k, v);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o){
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        KVParentPair<?, ?, ?> kvParentPair = (KVParentPair<?, ?, ?>) o;
        return Objects.equals(kvParentPair.k, super.k) &&
                Objects.equals(kvParentPair.v, super.v) && Objects.equals(kvParentPair.p,this.p);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.k, super.v,p);
    }
}
